package com.xqgl.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xqgl.bean.Complaint;
import com.xqgl.service.ComplaintDaoImp;

/**
 * Servlet implementation class addComplaintServlet
 */
@WebServlet("/addComplaintServlet")
public class addComplaintServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public addComplaintServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;Charset=utf-8");
		String villagename = request.getParameter("villagename");
		String complainants = request.getParameter("complainants");
		String complaintname = request.getParameter("complaintname");
		String complaintrea = request.getParameter("complaintrea");
		String complaintctime = request.getParameter("complaintctime");
		String complaintstate = request.getParameter("complaintstate");
		
		Complaint complaint = new Complaint();
		complaint.setVillagename(villagename);
		complaint.setComplainants(complainants);
		complaint.setComplaintname(complaintname);
		complaint.setComplaintrea(complaintrea);
		complaint.setComplaintctime(complaintctime);
		complaint.setComplaintstate(complaintstate);
		
		ComplaintDaoImp imp = new ComplaintDaoImp();
		try {
			imp.add(complaint);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("complaintlist.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
